package com.wjh.graduation.controller;

import com.wjh.graduation.service.BillService;
import com.wjh.graduation.util.Util;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created on 2022/2/12.
 *
 * @author Wu Jiahong
 */
@SpringBootTest
public class BillController {
	@Autowired
	Util util = new Util();
	@Autowired
	BillService billService;

	@Test
	public void test0() {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date beginTime = new Date("1/1/2022");
		System.out.println();
		//获得月末时间
		Date endTime = util.lastDay(beginTime);
		//创建改变时间变量
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(beginTime);
		//循环遍历一整个月时间
		for (Date b = beginTime; b.compareTo(endTime) != 1; calendar.add(Calendar.DAY_OF_MONTH, +1), b = calendar.getTime()) {
			System.out.println(format.format(b));
		}
	}


	@Test
	public void test1() {
		Date beginTime = new Date("1/1/2022");
		Date testTime = new Date("1/31/2022");
		//获得月末时间
		Date endTime = util.lastDay(beginTime);
		System.out.println(testTime);
		System.out.println(endTime);
		System.out.println(testTime.compareTo(endTime));
	}
}
